<template>
    <div class="task-list-wrap">
        <div style="flex: 1; flex-shrink: 0; overflow-y: hidden; display: flex; flex-direction: column">
            <flexbox justify="space-between" class="title" :style="{ padding: '12px 0 0px 16px', paddingLeft: isCollaspeTask ? '50px' : '16px' }">
                <span style="font-weight: bold">产品需求</span>
                <span style="margin-right: 16px; font-size: 12px; color: #505a6e; cursor: pointer" @click="showMoreList">查看列表</span>
            </flexbox>
            <ListA :system="system" style="height: calc(50% - 48px)" />
            <a-divider style="margin: 8px 0" />
            <ListB :system="system" style="height: calc(50% - 48px)" :isCollaspeTask="isCollaspeTask" />
        </div>
        <div class="add-wrap">
            <flexbox justify="center" class="add-btn" @click="handleAddItem">
                <PlusOutlined />
                <span class="margin-l-8">新建产品需求</span>
            </flexbox>
        </div>
    </div>
</template>

<script lang="ts">
import { PlusOutlined } from '@ant-design/icons-vue';
import ListA from './ListA.vue';
import ListB from './ListB.vue';
import { useRouter } from 'vue-router';
import { defineComponent, ref, unref, reactive, toRefs, nextTick } from 'vue';
export default defineComponent({
    components: {
        ListA,
        ListB,
        PlusOutlined
    },
    props: {
        isCollaspeTask: {
            type: Boolean,
            default: false
        },
        system: {
            type: Number,
            default: null
        }
    },

    setup(props) {
        const state = reactive<any>({});
        const router = useRouter();
        const handleAddItem = () => {
            router.push({
                path: '/sendRequire/createProductRequire',
                query: {
                    systemId: props.system
                }
            });
        };
        const showMoreList = () => {
            router.push({
                path: '/productRequire/productRequirements',
                query: {
                    systemId: props.system
                }
            });
        };
        return {
            ...toRefs(state),
            handleAddItem,
            showMoreList
        };
    }
});
</script>

<style scoped lang="less">
.task-list-wrap {
    width: 100%;
    height: calc(100vh - 135px);
    background: #f3f9ff;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    .title {
        font-size: 15px;
    }
    .add-wrap {
        position: absolute;
        bottom: 0;
        left: 8px;
        height: 44px;
        right: 8px;
        z-index: 100;
        padding: 0 0px 12px 0px;
        cursor: pointer;
        .add-btn {
            background: rgba(23, 35, 61, 0.03);
            height: 100%;
            border: 1px dashed @primary-color;
        }
    }
}
</style>